$(function () {
    $(".user-login").click(function () {
        login();
    })
})
//用户点击登录
function login() {
    if($(".phone").val() == ""){
        YDUI.dialog.toast('手机号码不能为空','none',function(){});
        return;
    }if($(".phone").val().length != 11){
        YDUI.dialog.toast('手机号码格式有误，请重新输入','none',function(){});
        return;
    }if($(".pwd").val() == ""){
        YDUI.dialog.toast('密码不能为空','none',function(){});
        return;
    }else {
        userLogin();//登录
    }
}
//登录
function userLogin() {
    $.ajax({
        type: "get",
        cache:true,
        url:"http://115.159.106.174:8080/vanoo/weixin/agent_login.do?fphone="+$(".phone").val()+"&wxpwd="+$(".pwd").val()+"&token=123",
        data: '',
        dataType: "json",
        beforeSend:function () {
        },
        complete:function () {
        },
        success: function(result){
            console.log(result);
            if(result.msg == "workerlogin"){
                YDUI.dialog.toast('登录成功','success',function(){});
                setTimeout(function () {
                    window.location.href = '';
                },1000)
            }else {
                YDUI.dialog.toast(result.msg,'error',function(){});
            }

        },error : function(e) {
            YDUI.dialog.toast(e.msg,'error',function(){});
        }
    });
}